﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;

namespace ViCode_LeVi.Utilities
{
    public static class UpdateBindingDataContext
    {
        public static void UpdateDataContext(FrameworkElement checkBinding)
        {
            ThreadHelper.Runner.RunInMainThread(() =>
                {
                    if (checkBinding != null)
                    {
                        var be = checkBinding.GetBindingExpression(FrameworkElement.DataContextProperty);
                        var oldBD = be.ParentBinding;
                        if (oldBD != null)
                        {
                            //BindingOperations.ClearBinding(checkBinding, FrameworkElement.DataContextProperty);
                            //BindingOperations.SetBinding(checkBinding, FrameworkElement.DataContextProperty, oldBD);
                        }
                    }
                });
        }
    }
}
